home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-25 | 5.5 KB | 241 lines | [TEXT/MPS ] |
- ;
- ; File: 604Performance.s
- ;
- ; Contains: 604 Performance Code
- ;
- ; Written by: dgc = Douglas George Clarke
- ;
- ; Copyright: © 1995 by Apple Computer, Inc., All Rights Reserved.
- ;
-
-
- ;******************************************************************************************
- ;
- ; Macro definitions used throughout the file
- ;
-
- ;
- ; Makecsect - Creates a new program section.
- ;
-
- MACRO
- makecsect &name
-
- function &name.[pr]
- csect &name.[pr]
-
- ENDM
-
- ;
- ; Makeexport - Exports the specified name so that other object files can reference it.
- ;
- MACRO
- makeexport &name
-
- &name export &name
-
- ENDM
-
- ;
- ; C_PROLOGUE - Glue code used to set up our environment when we get called from C.
- ;
-
- MACRO
- C_PROLOGUE &spaceToSave
-
- mflr r0 ;get link register
- stw r0,0x0008(SP) ;store the link resgister on the stack
- stwu SP,-&spaceToSave(SP) ;skip over the stack space where the caller
- ; might have saved stuff
- ENDM
-
- ;
- ; C_EPILOGUE - Glue code used to tear down our environment when we return to C.
- ;
-
- MACRO
- C_EPILOGUE &spaceToRestore
-
- lwz r0, 0x8+&spaceToRestore(SP) ;get the saved link register
- addic SP,SP,&spaceToRestore ;reset the stack pointer
- mtlr r0 ;reset the link register
- blr ; return via the link register
-
- ENDM
-
-
- ;******************************************************************************************
- ;
- ; Table of contents (TOC) entries
- ;
-
- tc .GetPMC[tc],.GetPMC
- tc .ClearPMC[tc],.ClearPMC
- tc .SetMMCR0[tc],.SetMMCR0
-
-
- ;******************************************************************************************
- ;
- ; void GetPMC( long *PMC1, long *PMC2)
- ;
- ; Copy the PMC Registers into the longs pointed at by PMC1 and PMC2
- ;
-
- makecsect .GetPMC
- makeexport .GetPMC
-
- ;
- ; High memory
- ;
-
- numFPRs: set 0 ; num non-volatile FPRs (FPRs 14-31) we use
- numGPRs: set 0 ; num non-volatile GPRs (GPRs 13-31) we use
- CalleesLocalVars: set 0 ; we do not have any
- CalleesParams: set 32 ; always leave space for GPRs 3-10
- linkageArea: set 24 ; constant comes from the PowerPC Runtime Architecture Document
-
- ;
- ; Low memory
- ;
-
- saveSpace: set linkageArea + CalleesParams + CalleesLocalVars + 4*numGPRs + 8*numFPRs
- gprsBase: set linkageArea + CalleesParams + CalleesLocalVars
-
-
- basePtr set r3
- numBytes set r4
- endPtr set r4
-
- C_PROLOGUE saveSpace
-
- ReadCounters:
- ; mfspr r5,953
- ; dc.l %011111 00101 11001 11101 0101010011 0
- dc.l %01111100101110011110101010100110
- stw r5,0(r3)
- ; mfspr r5,954
- ; dc.l %011111 00101 11010 11101 0101010011 0
- dc.l %01111100101110101110101010100110
- stw r5,0(r4)
-
- C_EPILOGUE saveSpace ;this tears down the stack and returns via a blr
-
- ;******************************************************************************************
- ;
- ; void ClearPMC( void)
- ;
- ; Clear the PMC1 Registers
- ;
-
- makecsect .ClearPMC
- makeexport .ClearPMC
-
- ;
- ; High memory
- ;
-
- numFPRs: set 0 ; num non-volatile FPRs (FPRs 14-31) we use
- numGPRs: set 0 ; num non-volatile GPRs (GPRs 13-31) we use
- CalleesLocalVars: set 0 ; we do not have any
- CalleesParams: set 32 ; always leave space for GPRs 3-10
- linkageArea: set 24 ; constant comes from the PowerPC Runtime Architecture Document
-
- ;
- ; Low memory
- ;
-
- saveSpace: set linkageArea + CalleesParams + CalleesLocalVars + 4*numGPRs + 8*numFPRs
- gprsBase: set linkageArea + CalleesParams + CalleesLocalVars
-
-
- C_PROLOGUE saveSpace
-
- ClearCounters:
- li r5,0
- ; mtspr r5,953
- ; dc.l %011111 00101 11001 11101 0111010011 0
- dc.l %01111100101110011110101110100110
- ; mtspr r5,954
- ; dc.l %011111 00101 11010 11101 0111010011 0
- dc.l %01111100101110101110101110100110
-
- C_EPILOGUE saveSpace ;this tears down the stack and returns via a blr
-
- ;******************************************************************************************
- ;
- ; void SetMMCR0( long PMC1Select, long PMC2Select, long user, long system)
- ;
- ; Build the MMCR0 word and store it in the MMCR0
- ;
-
- makecsect .SetMMCR0
- makeexport .SetMMCR0
-
- ;
- ; High memory
- ;
-
- numFPRs: set 0 ; num non-volatile FPRs (FPRs 14-31) we use
- numGPRs: set 0 ; num non-volatile GPRs (GPRs 13-31) we use
- CalleesLocalVars: set 0 ; we do not have any
- CalleesParams: set 32 ; always leave space for GPRs 3-10
- linkageArea: set 24 ; constant comes from the PowerPC Runtime Architecture Document
-
- ;
- ; Low memory
- ;
-
- saveSpace: set linkageArea + CalleesParams + CalleesLocalVars + 4*numGPRs + 8*numFPRs
- gprsBase: set linkageArea + CalleesParams + CalleesLocalVars
-
-
- PMC1Select set r3
- PMC2Select set r4
-
- C_PROLOGUE saveSpace
-
- SetTheMMCRO:
- rotlwi r7,r3,6
- or r7,r7,r4
- cmpi 0,0,r5,0
- bne @1
- addi r5,r0,$2000
- rotlwi r5,r5,16
- or r7,r7,r5
- @1 cmpi 0,0,r6,0
- bne @2
- addi r5,r0,$4000
- rotlwi r5,r5,16
- or r7,r7,r5
- @2
- ; mtspr r5,952
- ; dc.l %011111 00111 11000 11101 0111010011 0
- dc.l %01111100111110001110101110100110
-
- C_EPILOGUE saveSpace ;this tears down the stack and returns via a blr
-
- ;******************************************************************************************
- ;
- ; TVector for InternalFlushCacheRangePPC
- ;
-
- EXPORT GetPMC[ds]
- GetPMC csect GetPMC[ds]
- dc.l .GetPMC
- dc.l TOC[tc0]
- dc.l 0
-
- EXPORT ClearPMC[ds]
- ClearPMC csect ClearPMC[ds]
- dc.l .ClearPMC
- dc.l TOC[tc0]
- dc.l 0
-
- EXPORT SetMMCR0[ds]
- SetMMCR0 csect SetMMCR0[ds]
- dc.l .SetMMCR0
- dc.l TOC[tc0]
- dc.l 0
-
- END
-